package com.example.demo.config;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

public class DateConverter implements Converter<String, Date> {

	private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

	@Override
	public Date convert(String source) {
		if (StringUtils.isEmpty(source)) {
			return null;
		}
		try {
			return format.parse(source);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
